var mongoose = require('mongoose');
var Pic = require('../models/pic.model')// 引数据模型
var path=require('path');
var multer = require('multer');
var fs = require('fs');
var async = require('async');


exports.list = function(req,res,next){
    var page = (req.body.page) ? req.body.page : 1;
    var limit = (req.body.limit) ? req.body.limit : 7;

    var queryCondition = {};
    var cateId;
    if( req.body.title && req.body.title.trim().length>0 ){
        cateId = req.body.cateId;
        queryCondition = {"cateId":new RegExp(cateId,'t')}
    }


    Pic.paginate(queryCondition, { page: page, limit: limit }, function(err, result) {
        result.rows = result.docs;
        delete result.docs;
        
       res.json(result)
    });
}